/**
 * Project of Vehicle Routing Problem with Time Windows implements 
 * some of well-known algorithms for solving VRPTW.
 *
 * @author Michal Drobny  
 */

package logic.destination;

import java.util.UUID;

import logic.location.Location;
import logic.restriction.interfaces.HasCapacity;
import logic.restriction.interfaces.HasLocation;
import logic.restriction.interfaces.HasTimeDelay;
import logic.restriction.interfaces.HasTimeWindow;
import logic.timewindow.TimeWindow;

/**
 * Represents simple object for destination with time window, capacity and time
 * delay.
 * 
 * @author Michal Drobny
 * @date 16.10.2014
 */
public class SolomonInstanceDestination extends Destination implements
		HasTimeWindow<Long>, HasCapacity<Integer>, HasTimeDelay<Long>,
		HasLocation {

	private Long timeDelay;
	private TimeWindow<Long> timeWindow;
	private Integer capacity;
	private Location location;

	/**
	 * The constructor.
	 * 
	 * @param name
	 *            The name
	 */
	public SolomonInstanceDestination(String name) {
		super(name);
		this.timeWindow = null;
		this.capacity = -1;
		this.location = null;
		this.timeDelay = -1l;
	}

	/**
	 * The constructor.
	 * 
	 * @param name
	 *            The name
	 * @param id
	 *            The ID
	 */
	public SolomonInstanceDestination(String name, UUID id) {
		super(name, id);
		this.timeWindow = null;
		this.capacity = -1;
		this.location = null;
		this.timeDelay = -1l;
	}

	/**
	 * The constructor.
	 * 
	 * @param name
	 *            The name
	 * @param timeWindow
	 *            The time window
	 * @param capacity
	 *            The capacity
	 * @param location
	 *            The location
	 */
	public SolomonInstanceDestination(String name, TimeWindow<Long> timeWindow,
			Integer capacity, Location location, Long timeDelay) {
		super(name);
		this.timeWindow = timeWindow;
		this.capacity = capacity;
		this.location = location;
		this.timeDelay = timeDelay;
	}

	/**
	 * @param location
	 *            the location to set
	 */
	public void setLocation(Location location) {
		this.location = location;
	}

	/**
	 * @param capacity
	 *            the capacity to set
	 */
	public void setCapacity(Integer capacity) {
		this.capacity = capacity;
	}

	/**
	 * @param timeWindow
	 *            the timeWindow to set
	 */
	public void setTimeWindow(TimeWindow<Long> timeWindow) {
		this.timeWindow = timeWindow;
	}

	@Override
	public TimeWindow<Long> getTimeWindow() {
		return timeWindow;
	}

	/**
	 * @param timeDelay
	 *            the timeDelay to set
	 */
	public void setTimeDelay(Long timeDelay) {
		this.timeDelay = timeDelay;
	}

	@Override
	public Integer getCapacity() {
		return capacity;
	}

	@Override
	public Location getLocation() {
		return location;
	}

	@Override
	public Long getTimeDelay() {
		return timeDelay;
	}

	@Override
	public Destination clone() {
		TimeWindow<Long> clonedTimeWindow = null;
		if (getTimeWindow() != null)
			clonedTimeWindow = new TimeWindow<Long>(getTimeWindow().getStart(), getTimeWindow().getEnd());
		
		Location clonedLocation = null;
		if (getLocation() != null)
			clonedLocation = getLocation().clone();
		
		SolomonInstanceDestination clonedDestination = new SolomonInstanceDestination(getName(), getId());
		clonedDestination.setCapacity(getCapacity());
		clonedDestination.setTimeDelay(getTimeDelay());
		clonedDestination.setLocation(clonedLocation);
		clonedDestination.setTimeWindow(clonedTimeWindow);
		
		return clonedDestination;
	}
}